-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not overwrite openai.api_version. #4234
Conversation
@@ -106,7 +106,7 @@ class OpenAIEmbeddings(BaseModel, Embeddings): | |||
client: Any #: :meta private: | |||
model: str = "text-embedding-ada-002" | |||
deployment: str = model # to support Azure OpenAI Service custom deployment names | |||
openai_api_version: str = "2022-12-01" | |||
openai_api_version: str = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make default value ""
you can have a default value at https://github.com/hwchase17/langchain/pull/4234/files#diff-d7a6d6752d04755e0881f71a73e707932889769c486afac9ede77b92ea125cbbR147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pranjaldoshi96 I made the default value ""
according to other azure model implementations: https://github.com/zijie0/langchain/blob/96f4467b3c26eceae28cedd6a5180adbcda6cd9e/langchain/chat_models/azure_openai.py#L45
By making the default ""
, we are forcing user to define this variable either in env or in named parameter.
You remind me that this parameter should be optional with default OpenAI embeddings. So I also added openai_api_type
check in validation.
Hey @hwchase17 , could anyone take a look at this? I think it might solve many potential issues when using Azure OpenAI. |
@hwchase17 LGTM! I think it should solve my problem. |
I found an issue that the value of
openai.api_version
was modified after creating the embedding model:This will lead to many weird problems, such as environment variables and named parameter will NOT work in subsequent use of other Azure OpenAI models and lead to "Resource not found" errors (gpt-3.5 and gpt-4).
The fix is simple. But it may cause some regression error if user didn't set
OPENAI_API_VERSION
in environment variables nor pass it as a named parameter.